package com.ruoyi.experiment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.experiment.domain.CtfExperimentalEnvironmentExample;
import com.ruoyi.experiment.service.ICtfExperimentalEnvironmentExampleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * CTF实验环境实例列Controller
 * 
 * @author 邓鑫
 * @date 2023-07-29
 */
@RestController
@RequestMapping("/experiment/ctfexample")
public class CtfExperimentalEnvironmentExampleController extends BaseController
{
    @Autowired
    private ICtfExperimentalEnvironmentExampleService ctfExperimentalEnvironmentExampleService;

    /**
     * 查询CTF实验环境实例列列表
     */
    @PreAuthorize("@ss.hasPermi('experiment:ctfexample:list')")
    @GetMapping("/list")
    public TableDataInfo list(CtfExperimentalEnvironmentExample ctfExperimentalEnvironmentExample)
    {
        startPage();
        List<CtfExperimentalEnvironmentExample> list = ctfExperimentalEnvironmentExampleService.selectCtfExperimentalEnvironmentExampleList(ctfExperimentalEnvironmentExample);
        return getDataTable(list);
    }

    /**
     * 导出CTF实验环境实例列列表
     */
    @PreAuthorize("@ss.hasPermi('experiment:ctfexample:export')")
    @Log(title = "CTF实验环境实例列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CtfExperimentalEnvironmentExample ctfExperimentalEnvironmentExample)
    {
        List<CtfExperimentalEnvironmentExample> list = ctfExperimentalEnvironmentExampleService.selectCtfExperimentalEnvironmentExampleList(ctfExperimentalEnvironmentExample);
        ExcelUtil<CtfExperimentalEnvironmentExample> util = new ExcelUtil<CtfExperimentalEnvironmentExample>(CtfExperimentalEnvironmentExample.class);
        util.exportExcel(response, list, "CTF实验环境实例列数据");
    }

    /**
     * 获取CTF实验环境实例列详细信息
     */
    @PreAuthorize("@ss.hasPermi('experiment:ctfexample:query')")
    @GetMapping(value = "/{ctfEnvironmentExampleId}")
    public AjaxResult getInfo(@PathVariable("ctfEnvironmentExampleId") Long ctfEnvironmentExampleId)
    {
        return success(ctfExperimentalEnvironmentExampleService.selectCtfExperimentalEnvironmentExampleByCtfEnvironmentExampleId(ctfEnvironmentExampleId));
    }

    /**
     * 新增CTF实验环境实例列
     */
    @PreAuthorize("@ss.hasPermi('experiment:ctfexample:add')")
    @Log(title = "CTF实验环境实例列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CtfExperimentalEnvironmentExample ctfExperimentalEnvironmentExample)
    {
        return toAjax(ctfExperimentalEnvironmentExampleService.insertCtfExperimentalEnvironmentExample(ctfExperimentalEnvironmentExample));
    }

    /**
     * 修改CTF实验环境实例列
     */
    @PreAuthorize("@ss.hasPermi('experiment:ctfexample:edit')")
    @Log(title = "CTF实验环境实例列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CtfExperimentalEnvironmentExample ctfExperimentalEnvironmentExample)
    {
        return toAjax(ctfExperimentalEnvironmentExampleService.updateCtfExperimentalEnvironmentExample(ctfExperimentalEnvironmentExample));
    }

    /**
     * 删除CTF实验环境实例列
     */
    @PreAuthorize("@ss.hasPermi('experiment:ctfexample:remove')")
    @Log(title = "CTF实验环境实例列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ctfEnvironmentExampleIds}")
    public AjaxResult remove(@PathVariable Long[] ctfEnvironmentExampleIds)
    {
        return toAjax(ctfExperimentalEnvironmentExampleService.deleteCtfExperimentalEnvironmentExampleByCtfEnvironmentExampleIds(ctfEnvironmentExampleIds));
    }
}
